docs: response-extension import path guidance for context-specific schema variants#644
Open
bokelley wants to merge 1 commit into
Open
docs: response-extension import path guidance for context-specific schema variants#644bokelley wants to merge 1 commit into
bokelley wants to merge 1 commit into
Conversation
…hema variants Refs #642 (closed as not-actionable on SDK side). Several entity names (`Creative`, `Package`, `MediaBuy`, `Deployment`, `GeoCountriesExcludeItem`, etc.) are emitted as multiple distinct classes across spec slices. Top-level imports like `from adcp import Creative` resolve to one specific variant, typically not the one adopters want when extending response types. Subclassing the wrong variant fails silently at construction and surfaces as `mypy [assignment]` errors at the response override. This commit adds a "Picking the Right Base Class" section to extending-types.md covering: - Common cases with explicit submodule import paths (Creative listing vs delivery, Package, MediaBuy, Deployment, Geo*ExcludeItem mirrors) - How to detect the wrong import via mypy's [assignment] error - A pointer to the spec-level rename tracker (adcontextprotocol/adcp#4347) Also updates two existing examples in this guide that imported `Creative` from the top-level namespace to use the listing-slice path explicitly, matching the new guidance. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #642 (closed as docs-issue-not-codegen-bug after audit).
Problem
Several entity names appear in multiple spec slices as genuinely different shapes — `Creative` (full metadata in listing, 6-field shape in delivery, separate variant in sync result), `Package` (canonical vs response shape), `MediaBuy` (canonical vs capability declaration vs response), `Deployment` (RootModel wrapper vs structured `Deployment1`), and the `Geo*ExcludeItem` mirrors of `GeoCountry` etc.
Top-level imports like `from adcp import Creative` resolve to a single variant — typically the delivery-side one — silently. Adopters subclassing this for use in `ListCreativesResponse.creatives` get a class that constructs fine but trips `mypy [assignment]` and may silently drop fields the response expected.
What this PR does
Adds a new section "Picking the Right Base Class — Context-Specific Schema Variants" at the top of `docs/extending-types.md` covering:
Also updates two existing examples in the same guide that imported `Creative` from the top-level `adcp` namespace to use the listing-slice path explicitly, matching the new guidance.
Source of the cases
This guidance is derived from production usage in bokelley/salesagent, the most-advanced Python adopter. The audit traced every `# type: ignore[assignment]` in the salesagent schema package and identified which were genuine inheritance gaps (PR #640 `Sequence[X]` covers those) vs. cross-class confusion (this docs PR addresses those).
What this PR doesn't fix
The underlying friction — that adopters need to know spec slices to navigate imports — is a spec-level concern, tracked in adcontextprotocol/adcp#4347. When the rename ships, several of the cases in the lookup table dissolve. The Pydantic plugin handling of subclass field overrides is a separate concern (PR #640 partial fix). This docs PR addresses what adopters need today, with the right submodule path for each common case.
Test plan
🤖 Generated with Claude Code